package com.mashibing.tank.pojo;

import com.mashibing.tank.factory.BaseExplode;

import java.awt.*;

/**
 * @ClassName RectExplode
 * @Description 新的爆炸
 * @Author zhangjunhao
 * @DATE 2023/8/29 18:51
 */
public class RectExplode extends BaseExplode  {
    private static final int WIDTH = ResourceMgr.explodes[0].getWidth();
    private static final int HEIGHT = ResourceMgr.explodes[0].getHeight();
    private int x, y;

    private int step = 0;

    private TankFrame tankFrame;


    public RectExplode(int x, int y, TankFrame tankFrame) {
        this.x = x;
        this.y = y;
        this.tankFrame = tankFrame;

        //new Audio("com/mashibing/tank/audio/explode.wav").run();
    }

    public static int getWIDTH() {
        return WIDTH;
    }

    public static int getHEIGHT() {
        return HEIGHT;
    }


    @Override
    public void paint(Graphics g) {
        Color color = g.getColor();
        g.setColor(Color.red);
        g.fillRect(x, y,10*step, 10*step);
        step++;

        if ((step >= 5)) {
            tankFrame.getExplodes().remove(this);
        }
        g.setColor(color);
    }
}
